/* Helsinki University of Technology
 * T-106.530 Embedded Systems
 *
 * Car-project
 * HW abstraction layer
 *
 * Target: Atmel AVR ATmega32
 *
 * Author: Petri Hintukainen, 44020U
 * Date:   2012/03/16
 */

#ifndef __HAL_H_
#define __HAL_H_

#include <inttypes.h>

/*
 * Initialize hardware
 */

void car_init(void);
void car_reset(void);

/*
 * Wait for button press
 */

void car_wait_button_pressed(void);

/*
 * LED
 */

void car_set_led(int on);
void car_toggle_led(void);

/*
 * sleep
 * (accuracy ~ 128 us)
 */

void sleep_us(uint64_t us);

#define sleep_ms(ms) sleep_us(ms * UINT64_C(1000))

/*
 * Set car direction
 * angle: -85 ... 85 deg
 */

void car_set_direction(int8_t angle);

void car_stop(void);
void car_set_speed(int8_t speed);

/*
 * LCD
 */

void lcd_goto(uint8_t line, uint8_t col);
void lcd_string(const char *s);


#endif /* __HAL_H_ */
